import time
import unittest
from selenium import webdriver
from Page1 import Page1
from Page2 import Page2

class MyTestCase(unittest.TestCase):
    def setUp(self) -> None:
        self.driver = webdriver.Edge()
        self.driver.maximize_window()
        self.driver.implicitly_wait(30)
    def tearDown(self) -> None:
        time.sleep(2)
        self.driver.quit()
    def test1_register1_susses(self):
        po = Page1(self.driver)
        po.registeryewu('zhaoyun','123456')

        tj = po.get_text(po.tj)
        self.assertIn('提', tj)  # add assertion here
        self.assertEqual('提交', tj)
        po.tijiao()# add assertion here
        time.sleep(3)

    def test2_register2_fail(self):
        po = Page1(self.driver)
        po.registeryewu('', '123456')
        cz = po.get_text(po.tj)
        self.assertIn('用户',cz)
        self.assertEqual('重置', cz)
        po.tijiao()
        time.sleep(3)

    def test3_login1_susses(self):
        po = Page2(self.driver)
        po.registeryewu('zhaoyun', '123456')
        cz = po.get_text(po.userlogin)
        self.assertIn('登录', cz)
        self.assertNotEqual('注册', cz)
        po.login_a()
        time.sleep(3)

    def test4_login2_fail(self):
        po = Page2(self.driver)
        po.registeryewu('zhaoyun', '123456123')
        cz = po.get_text(po.userlogin)
        self.assertFalse('提交' == cz)
        self.assertEqual('重置', cz)
        po.login_a()
        time.sleep(3)
if __name__ == '__main__':
    unittest.main()
